﻿using UnityEngine;
using System.Collections;

public class LV2CharaAction : MonoBehaviour {


    protected Animator animator;

    public AudioSource m_singA;                //singA音效
    public AudioSource m_singB;                //singB音效


	// Use this for initialization
	void Start () {
        
        animator = GetComponent<Animator> ();
	
	}
	
	// Update is called once per frame
    void Update()
    {
    }

    void PlaySingA()
    {
        m_singA.Play();    
    }

    void PlaySingB()
    {
        m_singB.Play();
    }

    void StopSound()
    {
        m_singA.Stop();
        m_singB.Stop();
    }





    public bool singA()
    {
        AnimatorStateInfo state = animator.GetCurrentAnimatorStateInfo (0);
        if (state.IsName ("idle")) {
            animator.SetTrigger ("tSingA");

	    PlaySingA();

		return true;
		}

	return false;
	}

    public bool singB()
    {
        AnimatorStateInfo state = animator.GetCurrentAnimatorStateInfo (0);
        if (state.IsName ("idle")) {
	    animator.SetTrigger ("tSingB");

		PlaySingB();

		return true;
		}

	return false;
	}


	public bool Shutup()
	{
	    AnimatorStateInfo state = animator.GetCurrentAnimatorStateInfo (0);

	    if (state.IsName ("singA")||state.IsName("singB")) {
		    animator.SetTrigger ("tShutup");

		    StopSound();

		    return true;
	 	}

	    return false;
	}
	
	
}
